import api from '../request.js'
// 声明对象存储所有请求
let Obj = {}
// 获取预置post请求
const keys = Object.keys(api.post)
const vals = Object.values(api.post)
// 遍历注册请求
for (let i = 0 ; i < keys.length ; i ++) {
	const key = keys[i]
	Obj[key] = (obj) => {
		return new Promise((resolve, reject)=>{
			uni.request({
				url: api.url + vals[i],
				data: obj ? obj: null,
				header: {
					Authorization: `Bearer ${uni.getStorageSync('token')}`
				},
				method: 'post',
				success(res){
					resolve(res)
				},
				fail(res) {
					reject(res)
				}
			})
		})
	}
}
// 暴露请求
export default Obj

